import { VantComponent } from '../common/component';
import { button } from '../mixins/button';
import { openType } from '../mixins/open-type';
VantComponent({
    mixins: [button, openType],
    classes: ['hover-class', 'loading-class'],
    props: {
        plain: Boolean,
        block: Boolean,
        round: Boolean,
        square: Boolean,
        loading: Boolean,
        hairline: Boolean,
        disabled: Boolean,
        loadingText: String,
        formType:String,
        formidfsb:{
          type: Boolean,
          value: true
        },
        type: {
            type: String,
            value: 'default'
        },
        size: {
            type: String,
            value: 'normal'
        },
        loadingSize: {
            type: String,
            value: '20px'
        },
        styles:{
            type: String,
            value: ''
          },
          hoverClass:{
            type: String,
            value: ''
          },
          loadingColor:{
            type: String,
            value: '#fff'
          }
    },
    mounted:function(){
      
    },
    computed: {
        loadingColor:function loadingColor(){
          //wxutils.XkdNavTextColor()
          return this.data.loadingColor;
        },
        // classes: function classes() {
        //   var _this$data = this.data,
        //       type = _this$data.type,
        //       size = _this$data.size,
        //       block = _this$data.block,
        //       plain = _this$data.plain,
        //       round = _this$data.round,
        //       square = _this$data.square,
        //       loading = _this$data.loading,
        //       disabled = _this$data.disabled;
        //   return this.classNames('custom-class', 'van-button', "van-button--" + type, "van-button--" + size, {
        //     'van-button--block': block,
        //     'van-button--round': round,
        //     'van-button--plain': plain,
        //     'van-button--square': square,
        //     'van-button--loading': loading,
        //     'van-button--disabled': disabled,
        //     'van-button--unclickable': disabled || loading
        //   });
        // },
        styles:function styles(){
          return this.data.style;
        },
        hoverClass:function hoverClass(){
          return this.data.hoverClass;
        },
        formType:function formType(){
            return this.data.formType;
        }
      },
    methods: {
        loading(){
          this.setData({loading:true});
        },
        loaded(){
          this.setData({loading:false});
        },
        formSubmit(event){
          const myEventOption = {bubbles:true}
          if(this.data.formType=="submit")
          {
            this.$emit('submit',event.detail,myEventOption);//冒泡到框架层收集FormId，不要修改这个方法
          }
        },
        onClick(e) {
            if (!this.data.disabled && !this.data.loading) {
              this.$emit('click');
            }
        },
    }
});
